mui.init({
				pullRefresh:{
					container:"#refreshContainer",
					up:{
						callback:pullupRefresh
					}
				}
		});	
			var pagevalue =1;
			
			var _listArr,
				 areaIdentId='',
				streetIdentId=0,
				 workYear = 0,
				 searchIpt = '';
			var dataListArr = [];	//存储分页所有数据
			
			function pulldownRefresh(){
				$('.mui-pull').hide();
				setTimeout(function(){
					getHouseList(1,true,searchIpt,areaIdentId,workYear);
					mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
					mui('#refreshContainer').pullRefresh().enablePullupToRefresh();
					return pagevalue=1;
				},1000);
			}
			function pullupRefresh(){
				$('.mui-pull').show();
				setTimeout(function(){
					pagevalue++;
					getHouseList(pagevalue,false,searchIpt,areaIdentId,workYear);
				},1000);
			}
			
			mui.plusReady(function(){
				getHouseList(1,false,searchIpt,areaIdentId,workYear);
				mui('#houselist').on('tap','.agentDetail',function(event){
					event.stopPropagation();
					var _idx = $(this).parent('.agentList').index();
					openWindowWithPage('xol_agent_detail',{
						agentData:dataListArr[_idx]
					});
				});
				mui('#houselist').on('tap','.agentMobile',function(event){
					event.stopPropagation();
					var mobile = $(this).data('mobile');
//					console.log(mobile);
					var btnArray = ['拨打', '取消'];
					mui.confirm('是否拨打' + mobile + '?', '提示', btnArray, function(e) {
						if(e.index == 0) {
							plus.device.dial(mobile, false);
						}
					});
				});
				/*
				 * 选择区域
				 * */
				var currentCity = areaUtils.getCurrentCityChileAreaList();
				$('#areaTmpl').tmpl(currentCity).appendTo('#segmentedControls');
				
				var html = [];
				var contents = document.getElementById("segmentedControlContents");
				for (i in currentCity) {
					var finalAreaList = currentCity[i].arrayChildArea;
					html.push('<div id="content' + currentCity[i].id + '" class="mui-control-content"><ul class="mui-table-view">');
					for (j in finalAreaList) {
						html.push('<li class="mui-table-view-cell" id="'+finalAreaList[j].id+'">' + finalAreaList[j].areaName + '</li>');
					}
					html.push('</ul></div>');					
				}
				contents.innerHTML = html.join('');
				mui('#segmentedControls').on('tap','a',function(){	//选择区域
					pagevalue =1;
					dataListArr = [];	//清空分页数据列表
					areaIdentId = this.getAttribute('id');
					var idx = $(this).index();
					$('.mui-pull').hide();
					if(areaIdentId=='allArea'){		//不限区域
						areaIdentId = '';
						$('.mui-segmented-control .chooseArea').text('区域');
					}else{
						areaIdentId = this.getAttribute('id');
						$('.mui-segmented-control .chooseArea').text(this.text);
					}
					getHouseList(pagevalue, true, searchIpt, areaIdentId, workYear);////////////////
					$(this).parents('.house-tab-ul').addClass('mui-hidden');
					$('#bgZhezhao').hide();
					
				});		
				
				/*
				 * 搜索框搜索事件
				 * */
				document.querySelector('#openSearchPage_agent').addEventListener('keyup',function(e){
					pagevalue =1;
					searchIpt = this.value;
					dataListArr = [];
			        getHouseList(pagevalue,true,searchIpt,areaIdentId,workYear);
				},false);
				document.querySelector('#openSearchPage_agent').addEventListener('keydown',function(e){
					pagevalue =1;
					if(13 == e.keyCode){ //点击了“搜索”  
			           document.activeElement.blur();//隐藏软键盘 
			           searchIpt = $(this).val();
//			           console.log(searchIpt);
			           dataListArr = [];
			           getHouseList(pagevalue,true,searchIpt,areaIdentId,workYear);
			        } 
			    },false);
			});
			
			function getHouseList(pagevalue,isTrue,searchIpt,areaIdentId,workYear){
				
				var param = [{
					key:'searchKey',
					value:searchIpt
				},{
					key:'areaIdentId',
					value:areaIdentId
				},{
					key:'workYear',
					value:workYear
				},{
					key:'page',
					value:pagevalue
				},{
					key:'rows',
					value:10
				}];
				fjNetwork.get('fjzx/common/search-saleman.json',param,function(data){
					_listArr = data.rows;
					dataListArr = dataListArr.concat(_listArr);	//所有分页数据存储到新数组里面
					if(isTrue){
						document.querySelector('#houselist').innerHTML = '';
						mui('#refreshContainer').pullRefresh().enablePullupToRefresh();
						$('.mui-pull').hide();
					}
					
					$('#houseListTmpl').tmpl(_listArr,{
						getAverageScore:function(){
							var commentScore = this.data.commentScore;	//总分
							var commentTotal = this.data.commentTotal;	//总人数
							if(commentTotal){
								return (commentScore/commentTotal).toFixed(2);
							}else{
								return '暂无评分';
							}
							
						},
						agentStarFull: function(){
						var commentScore = this.data.commentScore;
						var commentTotal = this.data.commentTotal;
						var score = commentTotal==0?0 : parseInt(commentScore/commentTotal);
						var starStr = [];
//						console.log(score);
						starStr.length = parseInt(score);
						return starStr;
					},
					agentStarHalf: function(){
						var commentScore = this.data.commentScore;
						var commentTotal = this.data.commentTotal;
						var score = commentTotal==0?0 : parseInt(commentScore/commentTotal);
						var halfScore = parseInt(score);
						if(halfScore>score){
							return true;
						}else{
							return false;
						}
					},
					agentStar: function(){
						var commentScore = this.data.commentScore;
						var commentTotal = this.data.commentTotal;
						var score = commentTotal==0?0 : parseInt(commentScore/commentTotal);
						var rest = parseInt(5-score);
						var starStr = [];
						starStr.length = parseInt(rest);
						return starStr;
					}
					}).appendTo('#houselist');
					mui('#refreshContainer').pullRefresh().endPullupToRefresh(_listArr.length==0);
					
				},function(msg){
					mui.toast(msg);
				});
			}

	
	document.querySelector('.mui-segmented-control .tab-a').addEventListener('tap',function(){
		var _ul = document.querySelector('.house-tab-ul');
		_ul.classList.toggle('mui-hidden');
		$('#bgZhezhao').toggle();
	});

	
	$('#bgZhezhao').on('click',function(){
		$('.fj-house-tab-div').find('.house-tab-ul').addClass('mui-hidden');
		$(this).hide();
	});